/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.recorder.configuration;

import java.io.IOException;

import fr.uha.ensisa.jmp.drone.configuration.ConfigConsumer;
import fr.uha.ensisa.jmp.drone.configuration.Configurations;
import fr.uha.ensisa.jmp.drone.recorder.Recorder;


public class DroneConfigRecorder extends Recorder<String[]> implements ConfigConsumer
{
	private Configurations configuration  = new Configurations();

	public DroneConfigRecorder()
	{
		super(new DroneConfigWriter());
		try
		{
			start();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}

	public void start() throws IOException
	{
		super.start();
		((DroneConfigWriter)this.writer).open(this.configuration);
	}
	
	public synchronized Configurations getConfig()
	{
		return this.configuration;
	}
	

	@Override
	public void consume(String[] config)
	{
		try
		{
			this.record(config);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

	}		
}
